package com.myk.game.gobangchess;


import com.myk.game.gobangchess.constants.AppConfig;

import java.util.ArrayList;
import java.util.List;

/**
 * 历史记录类
 */
public class History {

    private final long startTime;
    private final List<String> historyStrList = new ArrayList<>();

    public History() {
        startTime = System.currentTimeMillis();
    }

    /**
     * 校验是否速刷
     * (从开始记录历史到保存到本地文件必须超过一定时间)
     */
    public boolean checkSaveSafeTime() {
        long curTime = System.currentTimeMillis();
        return curTime - startTime >= Long.parseLong(AppConfig.history_save_safe_time);
    }

    public void add(String historyStr) {
        historyStrList.add(historyStr);
    }

    public void addFirst(String historyStr) {
        historyStrList.add(0, historyStr);
    }

    public String toDataString() {
        StringBuilder a = new StringBuilder();
        for (String s : historyStrList) {
            a.append(s);
        }
        return a.toString();
    }
}
